<template>
	<view class="detail">
		<view v-if="detail">
			<view class="title">{{detail.title}}</view>
			<view class="time">{{detail.createdAt}}</view>
			<view class="hmtls" v-html="formatRichText(detail.content)"></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				detail: ''
			}
		},
		onLoad() {
			this.detail = uni.getStorageSync('news');
		},
		methods:{
			formatRichText(html){
			  let newContent= html.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"');
			  return newContent;
			}
		}
	}
	
</script>

<style lang="less" scoped>
	.detail {
		padding: 30rpx;
		.title {
			font-size: 32rpx;
			text-align: center;
			font-weight: bold;
		}
		.time {
			font-size: 24rpx;
			color: #999999;
			margin-bottom: 20rpx;
			margin-top: 10rpx;
		}
		.hmtls {
			image {
				width: 100%;
			}
			text-indent:2em
		}
	}
</style>
